package com.atguigu.yygh.common.component;

import com.atguigu.yygh.common.enums.QueueEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

/**
 * @author 孔德成
 * @slogan 致敬大师，致敬未来的你
 * @date 2021/9/14 7:06 下午
 * @desc
 */
@Slf4j
@Component
public class SuccessOrderSender {
    private final AmqpTemplate amqpTemplate;

    public SuccessOrderSender(AmqpTemplate amqpTemplate) {
        this.amqpTemplate = amqpTemplate;
    }

    public void sendMessage(Object message) {
        //给队列发送消息
        amqpTemplate.convertAndSend(QueueEnum.QUEUE_ORDER_SUCCESS.getExchange(), QueueEnum.QUEUE_ORDER_SUCCESS.getRouteKey(), message);
        log.info("send message to order queue:{}", message);
    }
}
